package com.example.controller;

import com.example.model.Student;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * Created by echisan on 2018/6/25
 */
@Controller
@RequestMapping("/student")
public class StudentController {

    @GetMapping
    public String renderStudent(HttpSession session, Model model){
        // 从session里拿出来，当然也可以写个过滤器或者拦截器，
        // 每次请求往session拿出来再set到model里去
        // 还有那个什么javabean啥的，好像能只能从session里去，忘了，不用那玩意了
        Student student = (Student) session.getAttribute("student");
        model.addAttribute("student", student);
        return "student";
    }
}
